<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Survey System</title>
        <link rel="stylesheet" href="http://res.61.com/css/manage/survey_main.css" type="text/css">
        <link rel="stylesheet" href="/html/js/ui/fbox/css/facebox.css" type="text/css">
    </head>
    <body>
        <div id="wrapper">
            <!--top start-->
            <div id="body_top">
                <span style="float:left">
                    <button id="addItembtn" class="clone">
                        添加项
                    </button>
                    <span class="additems"></span>
					 <button id="preview_btn">
                        预览
                    </button>
					<a href="javascript:;" id="back" style="display:none">返回</a>
					<span class="addthemeitems"></span>
					
				</span>
                <span style="float:right">
                    <button id="GET_DATA">
                        数据统计
                    </button>
					 <button id="CLEAR_DATA">
                        清空数据
                    </button>
                    <button id="GET_SCRIPT" class="script_modal">
                        获取脚本
                    </button>
                    <button id="save_all">
                        保存
                    </button>
                </span>
            </div>
            <!--top end-->
            <!--main start-->
            <div id="body_main">
                <div id="body_container">
                    <div id="title-desc">
                        <input type="text" id="form_title" name="form-title" class="input">
                        <textarea class="textarea" cols="50" rows="3" id="form_description" name="form-description" class="">
                        </textarea>
                    </div>
                    <div id="widget-container">
                    </div>
                </div>
				<div id="analizy_data" style="display:none">
				</div>
			</div>
            <!--main end-->
            <!--bottom start-->
            <div id="body_bottom" class="clear">
            	<div style="margin:5px auto auto 10px;">淘米调查问卷系统</div>
            </div>
            <!--bottom end-->
        </div>
		<script type="text/javascript" src="/html/js/base.js">
        </script>
        <script type="text/javascript" src="/html/js/web/survey.js">
        </script>
        <script type="text/javascript" src="/html/js/ui/fbox/js/facebox.js">
        </script>
		<script type="text/javascript" src="/html/js/admin/form.js">
        </script>
        <script>
            $(function(){
				
				$("#GET_SCRIPT").click(function(){
					$.facebox({
                        ajax: '/admin/admin_form/scriptpanel?key=' + formData.FormKey
                    });
				});
                $(window).resize(function(){
                    $left = ($(document).width() - $("#body_bottom").width()) / 2
                    $("#body_bottom").css("left", $left + "px");
					$("#body_container").height($(window).height()-70);
					$("#analizy_data").height($(window).height()-70);
					var scrollHeight_ = $("#body_container")[0].scrollHeight;
					var clientHeight_ = $("#body_container")[0].clientHeight;
					$(".form-widget-container").width(scrollHeight_-clientHeight_>0?"633px":"650px");
                });
				$("#body_container").height($(window).height()-70);
                $(window).trigger("resize");
                var formData = [$result.form];
				$(".list_btn .mt_btn").unbind("click").bind('click',function(e){
					var href_ = $(this).attr("href");
					var height_ = 0;
					var width_  = 0;
					var script_ = "";
					$.facebox({
                        ajax: '/admin/admin_form/getscript?key=' + formData.FormKey+"&action="+href_
                    });
					return false;
				});
                $("#GET_DATA").click(function(){
					$("#analizy_data").empty();
					$("#addItembtn").css("display","none");
                    $.ajax({
                        url: "/admin/admin_analizy/analizy?key=" + formData.FormKey,
                        type: "POST",
                        dataType: "html",
                        success: function(data){
                            $("#body_container").fadeOut(200,function(){
								$("#back").css("display",'');
								$("#GET_DATA").css("display","none");
								$("#analizy_data").height($(window).height()-70).append(data).fadeIn(200);
							});
                        }
                    });
                });
				$("#CLEAR_DATA").click(function(){
					$.facebox({
                        ajax: '/admin/admin_form/clearpanel?key=' + formData.FormKey
                    });
				});
				$("#back").bind("click",function(){
					 $("#analizy_data").fadeOut(200,function(){
							$("#back").css("display",'none');
							$("#GET_DATA").css("display","");
							$("#addItembtn").css("display","");
							$("#body_container").fadeIn(200);
					 });
				});
                var sur = new Survey(null, formData);
                $("#preview_btn").click(function(){
					$.facebox({
                        ajax: '/admin/admin_form/previewpanel?key=' + formData.FormKey
                    });
                });
				
            });
        </script>
    </body>
</html>
